package com.qiche.controller.mgr;

import com.qiche.aspect.Result;
import com.qiche.model.StoreMemberCar;
import com.qiche.service.StoreMemberCarService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 门店客户车辆信息管理控制器
 * @Author: Linzewen
 * @Date: 2018/5/4 0004 09:24
 */
@Api(value = "/storeMemberCar",description = "门店客户车辆信息管理控制器")
@RestController
@RequestMapping(value = "/storeMemberCar")
public class StoreMemberCarController {

    @Autowired
    private StoreMemberCarService storeMemberCarService;

    @ApiOperation(value = "添加或编辑门店客户车辆信息")
    @PostMapping
    public Result saveOrUpdate(@RequestBody StoreMemberCar car) {
       return storeMemberCarService.saveOrUpdate(car);
    }

    @ApiOperation(value = "根据ID删除门店客户车辆信息")
    @DeleteMapping(value = "/{id}")
    public Result delete(@PathVariable("id") Long id) {

        return storeMemberCarService.delete(id);
    }

    @ApiOperation(value = "根据门店客户ID查找该客户的车辆信息列表")
    @GetMapping(value = "/getCarsByStoreMember/{id}")
    public Result getCarsByCustomer(@PathVariable("id") Long storeMemberId) {
        List<StoreMemberCar> storeMemberCarList= storeMemberCarService.getCarsByStoreMemberId(storeMemberId);
        return Result.createBySuccess(storeMemberCarList);
    }

}
